[1]:
import emat
emat.versions()
emat 0.3.0, workbench 2.1.509, plotly 4.9.0
Meta-Model Creation¶
To demostrate the creation of a meta-model, we will use the Road Test example model included with TMIP-EMAT. We will first create and run a design of experiments, to have some experimental data to define the meta-model.
[2]:
import emat.examples
scope, db, model = emat.examples.road_test()
design = model.design_experiments(design_name='lhs')
results = model.run_experiments(design)
We can then create a meta-model automatically from these experiments.
[3]:
mm = model.create_metamodel_from_design('lhs')
mm
[3]:
<emat.PythonCoreModel "MetaModel1", metamodel_id=1 with 2 constants, 7 uncertainties, 4 levers, 7 measures>
If you are using the default meta-model regressor, as we are doing here, you can directly access a cross-validation method that uses the experimental data to evaluate the quality of the regression model. The cross_val_scores provides a measure of how well the meta-model predicts the experimental outcomes, similar to an
measure on a linear regression model.
[4]:
mm.cross_val_scores()
[4]:
no_build_travel_time 0.983936
build_travel_time 0.964524
time_savings 0.893910
value_of_time_savings 0.808775
net_benefits 0.626959
cost_of_capacity_expansion 0.928887
present_cost_expansion 0.954514
dtype: float64
We can apply the meta-model directly on a new design of experiments, and use the contrast_experiments visualization tool to review how well the meta-model is replicating the underlying model’s results.
[5]:
design2 = mm.design_experiments(design_name='lhs_meta', n_samples=5000)
results2 = mm.run_experiments(design2)
[6]:
from emat.analysis import contrast_experiments
contrast_experiments(mm.scope, results2, results)